package com.app.shop.adapters;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.app.shop.R;
import com.app.shop.beans.GoodsBean;

import com.app.library.utils.GlideUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;


public class GoodsListAdapter extends BaseQuickAdapter<GoodsBean, GoodsListAdapter.ViewHolder> {

    int from;

    public GoodsListAdapter(int layout, @Nullable List<GoodsBean> data, int from) {
        super(layout, data);
        this.from = from;
    }

    public GoodsListAdapter(int layout, @Nullable List<GoodsBean> data) {
        super(layout, data);
    }


    @Override
    protected void convert(ViewHolder holder, GoodsBean bean) {

        GlideUtils.getInstance().loadImage(mContext, bean.getGood_pic_path(), holder.imgv_pic);
        holder.tv_name.setText("" + bean.getGoods_name());
        holder.tv_remark.setText("类别：" + bean.getGoods_type());
        holder.tv_remark.setVisibility(View.GONE);
        holder.tv_mobile.setVisibility(View.GONE);
        holder.tv_price.setText("￥" + bean.getGoods_price());
//        holder.tv_mobile.setText("联系方式：" + bean.mobile);

        holder.tv_status.setVisibility(from == 1 ? View.VISIBLE : View.GONE);
        if (bean.status == 1) {
            holder.tv_status.setText("等待发货");
        } else if (bean.status == 2) {
            holder.tv_status.setText("点击收货");
        } else if (bean.status == 3) {
            holder.tv_status.setText("点击评论");
        }

        holder.tv_del.setVisibility(View.GONE);

        holder.addOnClickListener(R.id.tv_del_item).addOnClickListener(R.id.tv_pl);
    }


    public class ViewHolder extends BaseViewHolder {
        ImageView imgv_pic;
        TextView tv_name;
        TextView tv_remark;
        TextView tv_price;
        TextView tv_del;
        TextView tv_status;
        TextView tv_mobile;


        public ViewHolder(View view) {
            super(view);
            imgv_pic = view.findViewById(R.id.imgv_list);
            tv_name = view.findViewById(R.id.tv_list_item);
            tv_remark = view.findViewById(R.id.tv_list_type);
            tv_price = view.findViewById(R.id.tv_price);
            tv_del = view.findViewById(R.id.tv_del_item);
            tv_status = view.findViewById(R.id.tv_pl);
            tv_mobile = view.findViewById(R.id.tv_list_mobile);
        }
    }
}
